package com.atguigu.flink.sql.catalog;

import org.apache.flink.table.api.EnvironmentSettings;
import org.apache.flink.table.api.TableEnvironment;

/**
 * Created by Smexy on 2023/4/14
 * Catalog: 目录。
 *
 *      用来分目录管理元数据。
 *          举例:
 *              oracle  oracle.default.t1
 *              mysql   mysql.default.t1
 *
 *          flink多提供了一层路径，路径称为catalog，目录。
 *
 *              select * from mysql.default.t1;
 *
 *   ---------------------
 *      默认使用的 catalog 是 GenericInMemoryCatalog，把创建的表的元数据，存储在内存中。
 *
 */
public class Demo1_Catalog
{
    public static void main(String[] args) {

        EnvironmentSettings environmentSettings = EnvironmentSettings.newInstance().inStreamingMode().build();

        TableEnvironment tableEnvironment = TableEnvironment.create(environmentSettings);

        //default_catalog
        System.out.println(tableEnvironment.getCurrentCatalog());
        //default_database
        System.out.println(tableEnvironment.getCurrentDatabase());


       /* String createTableSql = " create table t1 ( id STRING, ts BIGINT , vc INT ," +
            "  `file.path` STRING NOT NULL METADATA " +
            "    )WITH (" +
            "  'connector' = 'filesystem'," +
            "  'path' = 'data/sensor.json'," +
            "  'format' = 'json'" +
            ") ";

        tableEnvironment.executeSql(createTableSql);*/

        tableEnvironment.sqlQuery(" select * from default_catalog.default_database.t1   ").execute().print();

    }
}
